//
//  Bundle+Ex.swift
//  Pods
//
//  Created by fff on 2025/2/7.
//


open class TSMyBundleClass {}

public extension Bundle {
    
    static var environmentName: String {
        let bundle = Bundle(for: TSMyBundleClass.self)  // 你的类名
        return bundle.infoDictionary?["CFBundleName"] as? String ?? "Unknown"
    }
    
    static var environmentBundle:Bundle{
        if let bundlePath = Bundle(for: TSMyBundleClass.self).path(forResource: environmentName, ofType: "bundle"),
           let bundle = Bundle(path: bundlePath) {
            return bundle
        } else {
            return Bundle.main
        }
    }
}

public extension UIImage {
    public convenience init?(bundleNamed name: String) {
        self.init(named: name, in: Bundle.environmentBundle, compatibleWith: nil)
    }
}
